import axios from 'axios'

export function UpdateContact(data) { //增加/编辑地址
  const url = baseURL + 'ttc.php/User/UpdateContact';
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function ContactLists(page) { //获取地址列表
  const url = baseURL + '/ttc.php/User/ContactLists';
  return axios.post(url, {
    "phpsid": localStorage.getItem('token'),//session_id
    'page': page
  }, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function getLngLat(data) { //获取经纬度
  const url = 'http://api.map.baidu.com/geocoder?address=' + data + '&output=json&key=3fd79baeb4cee83e753958b16086b97c'
  return axios.post(url, {}, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function setDefaultContact(data) { //设置默认地址
  const url = baseURL + '/ttc.php/User/setDefaultContact'
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function DeleteContact(data) { //删除
  const url = baseURL + 'ttc.php/User/DeleteContact'
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}
